<html>
<header>
<style>
body {
	background-color: #eeddff;
}
</style>
</header>
<body>
<script>
document.write('params:'+location.search);
</script>
<button onclick="myStopFunction()">Stop time</button>
<p id="demo"></p>
<script>
delay=parseInt(location.search.replace(/^.*delay=(.*)$|&/, "$1"));
if (isNaN(delay)) delay=1000;
//.parseInt();
window.onfocus = function () { txt += '{'; document.getElementById("demo").innerHTML = txt;};
window.onblur = function () { txt += '}'; document.getElementById("demo").innerHTML = txt;};
window.onbeforeunload  = function () { txt += '*'; document.getElementById("demo").innerHTML = txt;};
var myVar=setInterval(function(){myTimer()},delay);
lastNow = null;
var txt="";
function myTimer()
{
	var d=new Date();
	var t=Date.now();
	if (lastNow != null)
		txt+="["+(t-lastNow)+"]";
	txt = txt.substr(Math.max(txt.length-2000,0));
	document.getElementById("demo").innerHTML = txt;
	lastNow=t;
}
function myStopFunction()
{
clearInterval(myVar);
}
</script>
</body>
</html>